var db = require("../db/DbUtil");



/*
   定义一个异步函数
 */
var getAll2 = async()=>{

    var sql = "select depId,depName from Dep";
    //等待db.zsgc执行完了，才执行后面return
    /*db.zsgc(sql,null).then((value)=>{
      return value;
    }); */
    var result = await db.zsgc(sql,null);
    return result;
}

//async定义异步函数
async  function getAll()
{
    var sql = "select depId,depName from Dep";
    //等待db.zsgc方法执行完了，才赋值给result,再执行后面的return result
    var result = await  db.zsgc(sql,null,callback);
    return result;
}


async  function fenye(page, size)
{
    var sql = "select depId,depName from Dep limit ?,?";
    var param= [(page-1)*size,size*1];
    var result = await  db.zsgc(sql, param);
    return result;
}

module.exports={getAll,getAll2,fenye};